import os
import sys
import time
import random



def screencap(name):
    cmd = "adb shell /system/bin/screencap -p /sdcard/" + str(name) + ".png"
    do_commond(cmd)
    cmd = "adb pull /sdcard/" + str(name) + ".png ~/test/"
    do_commond(cmd)
    cmd = "adb shell rm /sdcard/" + str(name) + ".png"
    do_commond(cmd)

def do_commond(commond):
    os.system(commond)

if __name__ == '__main__':
    now_time = time.strftime("%H-%M-%S")
    screencap(now_time)